package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.UserLike;
import com.tanhua.model.mongo.Visitors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2021/11/7 14:17
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FriendsVo implements Serializable {
    private Long id; //用户id
    private String avatar; //用户头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String city; //城市
    private String education; //学历
    private Integer marriage; //婚姻状态
    private Integer matchRate; //匹配度
    private boolean alreadyLove; //是否喜欢

    public static FriendsVo init(UserInfo info, Visitors v) {
        FriendsVo vo = new FriendsVo();
        //copy用户属性
        BeanUtils.copyProperties(info, vo);  //source,target
        vo.setMatchRate(v.getScore().intValue());
        vo.setAlreadyLove(false);
        return vo;
    }

    public static FriendsVo init(UserInfo info, UserLike u, Integer type) {
        FriendsVo vo = new FriendsVo();
        //copy用户属性
        BeanUtils.copyProperties(info, vo);  //source,target
        vo.setMatchRate(0);
        vo.setAlreadyLove(type == 1 || type == 2);
        return vo;
    }
}